import { createRouter, createWebHistory } from 'vue-router'
import RegisterView from '@/views/Register/index.vue'
import LoginView from '@/views/Login/index.vue'
import HomeView from '@/views/Home/home.vue'
import IndexView from '@/views/Home/index.vue'
import FenView from '@/views/Home/fen.vue'
import CartView from '@/views/Home/cart.vue'
import MyView from '@/views/Home/my.vue'
import SearchView from '@/views/Search/index.vue'
import DetailView from '@/views/Detail/index.vue'
import OrderView from '@/views/Order/index.vue'
import GoodsView from '@/views/Goods/index.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect: '/home/index' },
    {
      path: '/register',
      component: RegisterView,
    },
    {
      path: '/login',
      component: LoginView,
    },
    {
      path: '/home',
      component: HomeView,
      children: [
        {
          path: 'index',
          component: IndexView,
        },
        {
          path: 'fen',
          component: FenView,
        },
        {
          path: 'cart',
          component: CartView,
        },
        {
          path: 'my',
          component: MyView,
        },
      ]
    },
    {
      path: '/search',
      component: SearchView,
    },
    {
      path: '/detail/:goods_id',
      component: DetailView,
    },
    {
      path: '/order/:orderid',
      component: OrderView,
    },
    {
      path: '/goods/:cat_name',
      component: GoodsView,
    },
  ],
})

export default router
